package demo.trendline;

import org.apache.commons.math3.geometry.euclidean.twod.Vector2D;
import org.apache.commons.math3.util.FastMath;

/**
 * @author Arnold Yand
 * @since Mar 18, 2017 3:09:18 PM
 * @summary demo.trendline.Vector2DDemo.java
 */
public class Vector2DDemo {

  public Vector2DDemo() {
    Vector2D direction = new Vector2D(1, 0); // x-axis
    Vector2D a = new Vector2D(1 - 0, -1 - 0);
    System.out.println("angle between a and direction is " + FastMath.toDegrees(Vector2D.angle(direction, a)) + " degrees");
    Vector2D b = new Vector2D(2 - 1, -1 - (-1));
    Vector2D c = new Vector2D(2 - 2, 0 - (-1));
    System.out.println("angle between b and direction is " + FastMath.toDegrees(Vector2D.angle(direction, b)) + " degrees");
    System.out.println("angle between c and direction is " + FastMath.toDegrees(Vector2D.angle(direction, c)) + " degrees");
    Vector2D abc = a.add(b).add(c);
    System.out.println("angle between direction and a+b+c is " + FastMath.toDegrees(Vector2D.angle(direction, abc)) + " degrees");

    System.out.println("======================");

  }

  public static void main(String[] args) {
    new Vector2DDemo();
  }

}
